﻿using RaptorEngine;
using RaptorEngine.Components.Drawable;
using RaptorEngine.Managers;

namespace OilRigSumoWrestlers.Entities.MenuItems
{
    class ExitToMenuItem : MenuItem
    {
        public ExitToMenuItem(DrawableText selectedText, DrawableText deselectedText)
            : base(selectedText, deselectedText) { }

        public override void Execute()
        {
            GameEngine.Instance.Debug.ClearData();
            //Destroy Game Over scene
            GameEngine.Instance.Scene.RemoveCurrentScene();
            //Destroy Game scene
            GameEngine.Instance.Scene.RemoveCurrentScene();

            GameEngine.Instance.Scene.StartCurrentScene();
            GameEngine.Instance.Scene.ShowCurrentScene();

            if (GameEngine.Instance.Network.State != NetworkManager.NetworkState.Offline)
                GameEngine.Instance.Network.State = NetworkManager.NetworkState.Ending;
        }
    }
}
